@extends('admin.layout')
@section('title','录播管理')
@section('content1')
    <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main" >
        <div class="col-md-12" id="content" >
            <div class="app_content_div" id="app_content_div_301Index">
                <h3>直播/录播管理</h3>
            </div>
            <div style="float:right;"><button type="button" class="btn btn-primary" onclick="window.location.href='/adm/video/add-video'">新增视频</button></div>
            <br><br><br>
            <form action="/adm/video/del-video" method="post">
            <table class="table table-striped">
                @csrf
                <thead>
                <tr>
                    <th>id</th>
                    <th>标题</th>
                    <th>科室</th>
                    <th>专家</th>
                    <th>类型</th>
                    <th>直播开始时间</th>
                    <th>直播结束时间</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                @foreach($oVideos as $v)@foreach($v->experts as $s)
                <tr>
                    <th scope="row">{{$v->id}}</th>
                    <td>{{$v->title}}</td>

                    <td>{{$s->department}}</td>
                    <td>{{$s->name}}</td>

                    <td>{{$v->type}}</td>
                    <td>{{$v->begin}}</td>
                    <td>{{$v->end}}</td>
                    <td>
                        <a href="/adm/video/edit-video/{{$v->id}}"><span class="glyphicon glyphicon-edit" aria-hidden="true"></span></a>
                        &nbsp;&nbsp;&nbsp;
                        <a onclick="delVideo({{$v->id}})"><span class="glyphicon glyphicon-trash" aria-hidden="true"></span></a>
                    </td>
                </tr>@endforeach
                @endforeach
                </tbody>
            </table>
            {{$oVideos->links('admin.page')}}

        </div>
    </div>
    </div>
    <script>
        function delVideo(id){
            if(confirm('确定要删除该条记录吗？')){
                var url="/adm/video/del-video";
                var token="{{@csrf_token()}}";
                $.post(url,{'_token':token,'id':id},function(data){
                    alert('已删除');
                    location.reload();
                });
            }
        }
    </script>
@endsection
